﻿<?php

include("../Modules/conn.php");

$tk = $_SESSION["taikhoan"];
$mslop = $_GET["mslop"];

// Tim nhat ky cho lop hoc phan duoc chon
$queryNK = "select * from nhat_ky where MS_LOP = '$mslop' and XAC_NHAN_SV = 'y' order by NG_HOC_GV";

$resultNK = mysql_query($queryNK, $conn) or die(mysql_error());
$count = mysql_num_rows($resultNK);

?>

<?php
	if ($count != 0)
	{
		// Tim ten sv dang thuc hien cap nhat nkgd
		$queryBM = "select TEN_BM from bo_mon where MSBM = '$tk'";
		$resultBM = mysql_query($queryBM, $conn) or die(mysql_error());
		$rowBM = mysql_fetch_array($resultBM);
		
		// Tim lop hoc phan dang duoc chon
		$queryLOPHP = "select TEN_LOP from lop_hp where MS_LOP = '$mslop'";
		$resultLOPHP = mysql_query($queryLOPHP, $conn) or die(mysql_error());
		$rowLOPHP = mysql_fetch_array($resultLOPHP);
		
		// Tim ten gv day lop hp dc chon
		$queryGV = "select TEN_CB from giang_vien a, lop_hp b where a.MSCB = b.MSCB and MS_LOP = '$mslop'";
		$resultGV = mysql_query($queryGV, $conn) or die(mysql_error());
		$rowGV = mysql_fetch_array($resultGV);
		
		
		
		echo '<table class="info" align="center">
		<tr><td class="name">Bộ môn: </td><td>'.$rowBM["TEN_BM"].'</td></tr>
		<tr><td class="name">Lớp: </td><td>'.$rowLOPHP["TEN_LOP"].'</td></tr>
		<tr><td class="name">Giảng viên: </td><td>'.$rowGV["TEN_CB"].'</td></tr></table>
		<table align="center">
		<tr><td class="tableHeader" colspan="4"><h4> NHẬT KÝ GIẢNG DẠY </h4></td></tr>
			<tr>
				<th>Ngày học</th>
				<th>Ngày ghi nhật ký</th>
				<th>Nội dung dạy</th>
				<th>CNBM</th>
			</tr>';
		
		while ($rowNK = mysql_fetch_array($resultNK))
		{
			echo '<tr>
					<td>'.$rowNK["NG_HOC_GV"].'</td>
					<td>'.$rowNK["NG_GHI_NK"].'</td>
					<td>'.$rowNK["NOI_DUNG_DAY_GV"].'</td>
					';
					
					if (($rowNK["XAC_NHAN_SV"] == "y") &&
						($rowNK["NG_HOC_SV"] == "") &&
						($rowNK["NOI_DUNG_DAY_SV"] == ""))
					{
							if ($rowNK["XAC_NHAN_BM"] == "y")
								echo '<td><p class="accepted">Đã duyệt</p></td>';
							else echo '<td><a href="../Modules/cnbm_xacnhan.php?stt='.$rowNK["STT"].'&mslop='.$mslop.'">Duyệt</a></td>	</tr>';
					}				
					else
					{
						echo '<tr><td>'.$rowNK["NG_HOC_SV"].'</td> <td></td> <td>'.$rowNK["NOI_DUNG_DAY_SV"].'</td>';
						if ($rowNK["XAC_NHAN_BM"] == "x")
							echo '<td><p class="timeout">Đã gửi yêu cầu xem lại</p></td>';
						else echo '<td><a href="../Modules/cnbm_xemlai.php?stt='.$rowNK["STT"].'&mslop='.$mslop.'">Xem lại</a></td>	</tr>';
					}
		}
		echo '</table>';
	}
	else echo '<p class="notExist">Chưa có nhật ký</p>';
?>